{template 'web/_header'}
{template 'tabs'}

{if $operation=='display'}
        <form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="sz_yi" />
            <input type="hidden" name="do" value="plugin" />
            <input type="hidden" name="p" value="coupon" />
            <input type="hidden" name="method" value="coupon" />
            <input type="hidden" name="op" value="display" />
			
<div class="panel panel-info">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">

            <div class="form-group">
              
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">优惠券名称</label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <input type="text" class="form-control"  name="keyword" value="{$_GPC['keyword']}" placeholder='可搜索优惠券名称'/> 
                </div>
            </div>
                  <div class="form-group">
                   <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">分类</label>
                    <div class="col-sm-9 col-xs-12">
			<select name='catid' class='form-control'>
				<option value=''></option>
				{loop $category $k $c}
					<option value='{$k}' {if $_GPC['catid']==$k}selected{/if}>{$c['name']}</option>
			          {/loop}
			</select>
                      
                    </div>
         </div>
              <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">类型</label>
              <div class="col-sm-8 col-lg-9 col-xs-12">
                    <select name='type' class='form-control'>
                        <option value=''></option>
                        <option value='0' {if $_GPC['type']=='0'}selected{/if}>购物</option>
                        <option value='1' {if $_GPC['type']=='1'}selected{/if}>充值</option>
                    </select>
                  </div>
               
                </div>
    <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">领取中心是否显示</label>
              <div class="col-sm-8 col-lg-9 col-xs-12">
                    <select name='gettype' class='form-control'>
                        <option value=''></option>
                        <option value='0' {if $_GPC['gettype']=='0'}selected{/if}>不显示</option>
                        <option value='1' {if $_GPC['gettype']=='1'}selected{/if}>显示</option>
                    </select>
                  </div>
               
                </div>
                  <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">创建时间</label>
                    <div class="col-sm-7 col-lg-9 col-xs-12">
                        <div class="col-sm-2">
                            <label class='radio-inline'>
                                <input type='radio' value='0' name='searchtime' {if $_GPC['searchtime']=='0'}checked{/if}>不搜索
                            </label> 
                             <label class='radio-inline'>
                                <input type='radio' value='1' name='searchtime' {if $_GPC['searchtime']=='1'}checked{/if}>搜索
                            </label>
                     </div>
                        {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d', $starttime),'endtime'=>date('Y-m-d ', $endtime)),true);}
                    </div>
                </div>
 
<div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
                <div class="col-sm-8 col-lg-9 col-xs-12">
                       <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
			<input type="hidden" name="token" value="{$_W['token']}" />
                    
                </div>
            </div>    
   
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-heading">总数:{$total} <small>排序数字越大越靠前</small></div>
    <div class="panel-body">
        <table class="table table-hover table-responsive">
            <thead class="navbar-inner" >
                <tr>
                     <th style='width:50px;'>ID</th>
                     <th style="width:80px;">排序</th>
                     <th>优惠券名称</th>
 <th >使用条件/优惠</th>
		  <th >已使用/已发出/剩余数量</th>
		  <th>领取中心</th>
		  <th >口令玩法人数/猜中人数</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                      <td>{$row['id']}</td>
					  <td>
			   {ifp 'coupon.coupon.edit'}
                           <input type="text" class="form-control" name="displayorder[{$row['id']}]" value="{$row['displayorder']}">
                        {else}
                           {$row['displayorder']}
                        {/if}
						</td>
                
		    <td>{if $row['coupontype']==0}
				  <label class='label label-success'>购物</label>
						  {else}
						  <label class='label label-warning'>充值</label>
					 {/if}
					 {if !empty($row['catid'])}
					 <label class='label label-primary'>{$category[$row['catid']]['name']}</label>
					 {/if}
					 <br/>{$row['couponname']}
					  </td>
					  <td>{if $row['enough']>0}
						  <label class="label label-danger">满{$row['enough']}可用</label>
						  {else}
						    <label class="label label-warning">不限</label>
						  {/if}
					 
						  <br/>{if $row['backtype']==0}
						  立减 {$row['deduct']} 元
						  {else if $row['backtype']==1}
						  打 {$row['discount']} 折
						  {else if $row['backtype']==2}
						  {if $row['backmoney']>0}返 {$row['backmoney']} 余额;{/if}
						  {if $row['backcredit']>0}返 {$row['backcredit']} 积分;{/if}
						  {if $row['backredpack']>0}返 {$row['backredpack']} 红包;{/if}
						  {/if}
					 </td>
					 
                    <td>
                                            {ifp 'coupon.log.view'}
                                            <a href="{php echo $this->createPluginWebUrl('coupon/log',array('coupon'=>$row['id']))}">
                                                 {$row['usetotal']} / {$row['gettotal']} / {if $row['total']==-1}无限数量{else}{php echo $row['total'] -  $row['gettotal']}{/if}
                                            </a>
                                            {else}
                                             {$row['usetotal']} / {$row['gettotal']} / {if $row['total']==-1}无限数量{else}{php echo $row['total'] -  $row['gettotal']}{/if}
                                            {/if}
                                      
                     <td>{if $row['gettype']==0}
						 <label class="label label-default">不显示</label>
						 {else}
						 
						 {if $row['credit']>0 || $row['money']>0}
						 {if $row['credit']>0}<label class='label label-primary'>{$row['credit']} 积分</label><br/>{/if}
						 {if $row['money']>0}<label class='label label-danger'>{$row['money']} 现金</label><br/>{/if}
						 {else}
						 <label class='label label-warning'>免费</label>
						 {/if}
					 {/if}
					 </td>
					 <td>{$row['pwdjoins']} / {$row['pwdoks']}</td>
					<td>{php echo date('Y-m-d',$row['createtime'])}</td>
					<td style="position:relative">
						<a href="javascript:;" data-url="{php echo $this->createPluginMobileUrl('coupon/detail', array('id' => $row['id']))}"  title="复制连接" class="btn btn-default btn-sm js-clip"><i class="fa fa-link"></i></a>
						
                         {ifp 'coupon.coupon.edit'} 
                              <a class='btn btn-default btn-sm' href="{php echo $this->createPluginWebUrl('coupon/coupon/post',array('id' => $row['id']));}" title="编辑" ><i class='fa fa-edit'></i></a>
							 
                        {/if}
                        {ifp 'coupon.coupon.delete'} 
                              <a class='btn btn-default  btn-sm' href="{php echo $this->createPluginWebUrl('coupon/coupon/delete',array('id' => $row['id']));}" title="删除" onclick="return confirm('确定要删除该优惠券吗？');"><i class='fa fa-remove'></i></a>
							 
                        {/if}
                        
                       {ifp 'coupon.coupon.send'} 
                              <a  class='btn btn-primary  btn-sm' href="{php echo $this->createPluginWebUrl('coupon/send',array('couponid' => $row['id']));}" title="发放优惠券" ><i class='fa fa-send'></i></a>
							
                        {/if}
                             </ul>
                       </div>

               
                    </td>
                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
    <div class='panel-footer'>
                           	   {ifp 'article.page.edit'}
                          <input name="submit" type="submit" class="btn btn-primary" value="提交排序">
                        {/if}
        {ifp 'coupon.coupon.add'}                   
                  <a class='btn btn-default' href="{php echo $this->createPluginWebUrl('coupon/coupon',array('op'=>'post'))}"><i class='fa fa-plus'></i> 添加购物优惠券</a>
		<a class='btn btn-default' href="{php echo $this->createPluginWebUrl('coupon/coupon',array('op'=>'post','type'=>1))}"><i class='fa fa-plus'></i> 添加充值优惠券</a>
        {/if}
    </div>
</div>
			     </form>
{else if $operation=='post'}

<form {ife 'coupon.coupon.edit' $item}action="" method='post'{/if} class='form-horizontal'>
    <input type="hidden" name="id" value="{$item['id']}">
    <input type="hidden" name="op" value="detail">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="sz_yi" />
    <input type="hidden" name="p" value="coupon" />
    <input type="hidden" name="method" value="coupon" />
    <input type="hidden" name="op" value="post" />
    <div class='panel panel-default'>
        <div class='panel-heading'>
            编辑{if $type==0}购物{else}充值{/if}优惠券
        </div>
		
   <div class='panel-body'>
        <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
               <div class="col-sm-5">
                    {ife 'coupon.coupon' $item}
                    <input type="text" name="displayorder" class="form-control" value="{$item['displayorder']}"  />
		 <span class='help-block'>数字越大越靠前</span>
                    {else}
                    <div class='form-control-static'>{$item['displayorder']}</div>
                    {/if}
                </div>
        </div>
	 
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 优惠券名称</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                    <input type="text" name="couponname" class="form-control" value="{$item['couponname']}"  />
                    {else}
                    <input type="hidden" name="couponname" class="form-control" value="{$item['couponname']}"  />
                    <div class='form-control-static'>{$item['couponname']}</div>
                    {/if}
                </div>
        </div>
 
			
        <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">分类</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'coupon.coupon' $item}
						<select name='catid' class='form-control'>
							<option value=''></option>
							{loop $category $k $c}
								<option value='{$k}' {if $item['catid']==$k}selected{/if}>{$c['name']}</option>
							 {/loop}
						</select>
                        {else}
                             <div class='form-control-static'>{if empty($item['catid'])}暂时无分类{else} {$category[$item['catid']]['name']}{/if}</div>
                        {/if}
                    </div>
         </div>
							  <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">缩略图</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'coupon.coupon' $item}
                        {php echo tpl_form_field_image('thumb', $item['thumb'])}
                        {else}
                        <input type="hidden" name="thumb" value="{$item['thumb']}"/>
                        {if !empty($item['thumb'])}
                        <a href='{php echo tomedia($item['thumb'])}' target='_blank'>
                           <img src="{php echo tomedia($item['thumb'])}" style='width:100px;border:1px solid #ccc;padding:1px' />
                        </a>
                        {/if}
                        {/if}
                    </div>
                </div>
         <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">使用条件</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                    <input type="text" name="enough" class="form-control" value="{$item['enough']}"  />
                    <span class='help-block' >{if empty($type)}消费{else}充值{/if}满多少可用, 空或0 不限制</span>
                    {else}
                    <div class='form-control-static'>{if $item['enough']>0}满 {$item['enough']} 可用 {else}不限制{/if}</div>
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">使用时间限制</label>
                
                    {ife 'coupon.coupon.edit' $item}
                    <div class="col-sm-3">
                    <div class='input-group'>
                        <span class='input-group-addon'>
                             <label class="radio-inline" style='margin-top:-5px;' ><input type="radio" name="timelimit" value="0" {if $item['timelimit']==0}checked{/if}>获得后</label>
                        </span>
                   
                     <input type='text' class='form-control' style="width:50px;" name='timedays' value="{$item['timedays']}" />
                     <span class='input-group-addon'>天内有效(空为不限时间使用)</span>
                      </div>
                     </div>
                    
                     <div class="col-sm-2">
                    <div class='input-group'>
                        <span class='input-group-addon'>
                             <label class="radio-inline" style='margin-top:-5px;' ><input type="radio" name="timelimit" value="1" {if $item['timelimit']==1}checked{/if}>日期</label>
                        </span>
                         {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d', $starttime),'endtime'=>date('Y-m-d', $endtime)));}
                          <span class='input-group-addon'>内有效</span>
                      </div>
                     </div>
                       {else}
                       <div class="col-sm-9 col-xs-12">
                      <div class='form-control-static'>
						  {if $item['timelimit']==0}
                          {if !empty($item['timedays'])}获得后 {$item['timedays']} 天内有效{else}不限时间{/if}
                          {else}
                          {php echo date('Y-m-d',$starttime)} - {php echo date('Y-m-d',$endtime)}  范围内有效
                          {/if}</div>
                      </div>
                    {/if}
              
            </div>
            {if empty($type)}
			{template 'coupon/consume'}
			{else}
			{template 'coupon/recharge'}
			{/if}
			

<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">领券中心是否可获得</label>
    <div class="col-sm-9 col-xs-12" >
          {ife 'coupon.coupon' $item}
        <label class="radio-inline">
            <input type="radio" name="gettype" value="0" {if $item['gettype'] == 0}checked="true"{/if}  onclick="$('.gettype').hide()"/> 不可以
        </label>
		          <label class="radio-inline">
            <input type="radio" name="gettype" value="1" {if $item['gettype'] == 1}checked="true"{/if} onclick="$('.gettype').show()" /> 可以
        </label>
		  <span class='help-block'>会员是否可以在领券中心直接领取或购买</span>
		
          {else} <div class='form-control-static'>
             {if $item['gettype']==1}可以{else}不可以{/if}
          </div>
          {/if}
    </div>
</div>
	     <div class="form-group gettype" {if $item['gettype']!=1}style="display:none"{/if}>
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                        <div class="col-sm-6">
                              {ife 'coupon.coupon' $item}
                            <div class="input-group">
			  <span class="input-group-addon">每个限领</span>
			  <input type='text' class='form-control' value="{$item['getmax']}" name='getmax'/>
                                <span class="input-group-addon">张 消耗</span>
                             <input type='text' class='form-control' value="{$item['credit']}" name='credit'/>
                             <span class="input-group-addon">积分 + 花费</span>
                                <input type='text' class='form-control' value="{$item['money']}" name='money'/>
                              <span class="input-group-addon">元&nbsp;&nbsp;
                                  <label class="checkbox-inline" style='margin-top:-8px;'>
                                    <input type="checkbox" name='usecredit2' value="1" {if $item['usecredit2']==1}checked{/if} /> 优先使用余额支付
                                </label>
                              </span></div>
                              <span class="help-block">每人限领，空不限制，领取方式可任意组合，可以单独积分兑换，单独现金兑换，或者积分+现金形式兑换, 如果都为空，则可以免费领取</span>
                                                       {else}
                             <div class='form-control-static'>消耗 {$item['credit']} 积分 花费 {$item['money']} 元现金</div>
                             {/if} 
                             </div>
      
                    </div>
		　                    
         <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">发放总数</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                    <input type="text" name="total" class="form-control" value="{$item['total']}"  />
                    <span class='help-block' >优惠券总数量，没有不能领取或发放,-1 为不限制张数</span>
                    {else}
                    <div class='form-control-static'>{if $item['total']==-1}无限数量{else}剩余 {$item['total']} 张{/if}</div>
                    {/if}
                </div>
   </div>
	 
　     </div>
		　
　     <div class='panel-heading'>
            使用说明
        </div>
        <div class='panel-body'>
			
			    <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否使用统一说明 </label>
                <div class="col-sm-9 col-xs-12">
                   {ife 'coupon.coupon' $item}
				   <label class="radio-inline" >
					<input type="radio" name="descnoset" value="0" {if $item['descnoset'] == 0}checked="true"{/if} /> 使用
				</label>
			   
                         <label class="radio-inline"'>
					<input type="radio" name="descnoset" value="1" {if $item['descnoset'] == 1}checked="true"{/if} /> 不使用
				</label>
				   <span class='help-block'>统一说明在<a href="{php echo $this->createPluginWebUrl('coupon/set')}" target='_blank'>【基础设置】</a>中设置，如果使用统一说明，则在优惠券说明前面显示统一说明</span>
						{else}
						
						<div class='form-control-static'>
						  {if $item['descnoset']==0}
						  使用
						  {else if $item['descnoset']==1}
						 不使用
						  {else}
						  {/if}
					  </div>
						{/if}
                </div>
            </div>
			
						
			<div class="form-group">
	<label class="col-xs-12 col-sm-3 col-md-2 control-label">使用说明</label>
	<div class="col-sm-9 col-xs-12">
                  {ife 'coupon.coupon' $item}
                            {php echo tpl_ueditor('desc',$item['desc'])}
                            {else}
                            <textarea id='desc' style='display:none'>{$item['desc']}</textarea>
                            <a href='javascript:preview_html("#desc")' class="btn btn-default">查看内容</a>
                            {/if}
	</div>
		</div>   </div>
               <div class='panel-heading'>
            推送消息 (发放或用户从领券中心获得后的消息推送，如果标题为空就不推送消息)
        </div>
			<div class='panel-body'>
			
				
				  <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">推送标题</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                    <input type="text" name="resptitle" class="form-control" value="{$item['resptitle']}"  />
		  <span class="help-block">变量 [nickname] 会员昵称 [total] 优惠券张数</span>
                    {else}
                    <div class='form-control-static'>{$item['resptitle']}</div>
                    {/if}
                </div>
            </div>
				  <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">推送封面</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'coupon.coupon' $item}
                        {php echo tpl_form_field_image('respthumb', $item['respthumb'])}
                        {else}
                        <input type="hidden" name="respthumb" value="{$item['respthumb']}"/>
                        {if !empty($item['thumb'])}
                        <a href='{php echo tomedia($item['respthumb'])}' target='_blank'>
                           <img src="{php echo tomedia($item['respthumb'])}" style='width:100px;border:1px solid #ccc;padding:1px' />
                        </a>
                        {/if}
                        {/if}
                    </div>
                </div>
				
				    <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">推送说明</label>
                <div class="col-sm-9 col-xs-12">
                     {ife 'coupon.coupon' $item}
                    <textarea name="respdesc" class='form-control'>{$item['respdesc']}</textarea>
					  <span class="help-block">变量 [nickname] 会员昵称 [total] 优惠券张数</span>
                       {else}
                      <div class='form-control-static'>{$item['respdesc']}</div>
                    {/if}
                </div>
            </div>
				  <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">推送连接</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                    <input type="text" name="respurl" class="form-control" value="{$item['respurl']}"  />
					<span class='help-block'>消息推送点击的连接，为空默认为优惠券详情</span>
                    {else}
                    <div class='form-control-static'>{$item['respurl']}</div>
                    {/if}
                </div>
            </div>	
			</div>
	  
	  
	<div class='panel-heading'>
            口令玩法 (用户发送关键词猜取优惠券)
        </div>
	<div class='panel-body'>
		
		<div class="form-group">
    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开启口令玩法</label>
    <div class="col-sm-9 col-xs-12" >
          {ife 'coupon.coupon' $item}
        <label class="radio-inline">
            <input type="radio" name="pwdopen" value="0" {if $item['pwdopen'] == 0}checked="true"{/if} onclick="$('.couponkey').hide()"  /> 关闭
        </label>
		          <label class="radio-inline">
            <input type="radio" name="pwdopen" value="1" {if $item['pwdopen'] == 1}checked="true"{/if} onclick="$('.couponkey').show()"  /> 开启
        </label>
          {else} 
	 <div class='form-control-static'>
             {if $item['pwdopen']==1}开启{else}关闭{/if}
          </div>
          {/if}
    </div>
</div>
		
	<div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">开始活动关键词</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                    <input type="text" name="pwdkey" class="form-control" value="{$item['pwdkey']}"  />
		  <span class="help-block">从平台获取优惠券的回复关键词,如果设置关键词为空，则不使用口令玩法，如果更换关键词，则表示开启另一轮活动</span>
                    {else}
                    <div class='form-control-static'>{$item['pwdkey']}</div>
                    {/if}
                </div>
            </div>
 	 <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">口令集</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                      <textarea name="pwdwords" class='form-control'>{$item['pwdwords']}</textarea>
		  <span class="help-block">可以多个口令, 用半角逗号隔开,口令不要与其他系统关键词重复</span>
                    {else}
                    <div class='form-control-static'>{$item['pwdwords']}</div>
                    {/if}
                </div>
            </div>
		
	     <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">每人猜测机会</label>
                <div class="col-sm-9 col-xs-12">
                     {ife 'coupon.coupon' $item}
                    <input name="pwdtimes" class='form-control' value='{$item['pwdtimes']}'>
			<span class="help-block">每人机会，空或0为不限制 </span>
                       {else}
                      <div class='form-control-static'>{if empty($item['pwdtimes'])}不限制{else}{$item['pwdtimes']}次{/if}</div>
					  
                    {/if}
                </div>
            </div>
	     <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">提示语</label>
                <div class="col-sm-9 col-xs-12">
                     {ife 'coupon.coupon' $item}
                    <textarea name="pwdask" class='form-control'>{$item['pwdask']}</textarea>
			<span class="help-block">默认: 请输入优惠券口令: </span>
			<span class='help-block'>变量: [nickname] 会员昵称 [couponname] 优惠券名称 [times] 已猜测次数 [lasttimes] 剩余猜测次数</span>
                       {else}
                      <div class='form-control-static'>{if empty($item['pwdask'])}请输入优惠券口令:{else}{$item['pwdask']}{/if}</div>
					  
                    {/if}
                </div>
            </div>
	
	   <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">猜中提示语</label>
                <div class="col-sm-9 col-xs-12">
                     {ife 'coupon.coupon' $item}
                       <textarea name="pwdsuc" class='form-control'>{$item['pwdsuc']}</textarea>
		     <span class="help-block">默认: 恭喜你，猜中啦！优惠券已发到您账户了!</span>
			 <span class='help-block'>变量: [nickname] 会员昵称 [couponname] 优惠券名称 [times] 已猜测次数 [lasttimes] 剩余猜测次数</span>
                       {else}
                      <div class='form-control-static'>{if empty($item['pwdsuc'])}恭喜你，猜中啦！优惠券已发到您账户了!{else}{$item['pwdsuc']}{/if}</div>
					  
                    {/if}
                </div>
            </div>
	
	  <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">猜错提示语</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                    <textarea name="pwdfail" class='form-control'>{$item['pwdfail']}</textarea>
		  <span class='help-block'>默认: 很抱歉，您猜错啦，继续猜~</span>
		  <span class='help-block'>变量: [nickname] 会员昵称 [couponname] 优惠券名称 [times] 已猜测次数 [lasttimes] 剩余猜测次数</span>
                    {else}
                    <div class='form-control-static'>{if empty($item['pwdfail'])}很抱歉，您猜错啦，继续猜~{else}{$item['pwdfail']}{/if}</div>
		  
                    {/if} 
                </div>
            </div>	
	   <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">猜测次数超出限制提示</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                     <textarea name="pwdfull" class='form-control'>{$item['pwdfull']}</textarea>
		  <span class='help-block'>默认: 很抱歉，您已经没有机会啦~</span>
		  <span class='help-block'>变量: [nickname] 会员昵称 [couponname] 优惠券名称 [times] 已猜测次数 [lasttimes] 剩余猜测次数</span>
                    {else} 
                    <div class='form-control-static'>{if empty($item['pwdfull'])}很抱歉，您已经没有机会啦~{else}{$item['pwdfull']}{/if}</div>
                    {/if}
                </div>
            </div>	
	     <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">退出口令</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                    <input type="text" name="pwdexit" class="form-control" value="{$item['pwdexit']}"  />
		  <span class="help-block">如果设置有次数限制，用户继续猜了，可输入退出口令，默认为0</span>
                    {else}
                    <div class='form-control-static'>{$item['pwdexit']}</div>
                    {/if}
                </div>
            </div>
		   <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">退出后提示</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                     <textarea name="pwdexitstr" class='form-control'>{$item['pwdexitstr']}</textarea>
		   <span class='help-block'>默认: 好的，等待您下次来玩!</span>
		  <span class='help-block'>变量: [nickname] 会员昵称 [couponname] 优惠券名称 [times] 已猜测次数 [lasttimes] 剩余猜测次数</span>
		  
                    {else}
                    <div class='form-control-static'>{if empty($item['pwdexitstr'])}很好的，等待您下次来玩!{else}{$item['pwdexitstr']}{/if}</div>
                    {/if}
                </div>
            </div>
		
	  <div class="form-group couponkey" {if empty($item['pwdopen'])}style="display:none"{/if}>
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">已获得提示</label>
                <div class="col-sm-9 col-xs-12">
                    {ife 'coupon.coupon' $item}
                     <textarea name="pwdown" class='form-control'>{$item['pwdown']}</textarea>
		  <span class='help-block'>默认: 您已经参加过啦,等待下次活动吧~</span>
		  <span class='help-block'>变量: [nickname] 会员昵称 [couponname] 优惠券名称 [times] 已猜测次数 [lasttimes] 剩余猜测次数</span>
                    {else} 
                    <div class='form-control-static'>{if empty($item['pwdown'])}您已经参加过啦,等待下次活动吧~{else}{$item['pwdown']}{/if}</div>
                    {/if}
                </div>
            </div>	 
			</div>
            
            <div class="form-group"></div>
            <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                         {ife 'coupon.coupon' $item}
                            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1"  />
                            <input type="hidden" name="token" value="{$_W['token']}" />
                        {/if}
                       <input type="button" name="back" onclick='history.back()' {ife 'coupon.coupon' $item}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
                    </div>
            </div>


        </div>


    </div>   
   
</form>
<script language='javascript'>
    
    function showbacktype(type){
 
        $('.backtype').hide();
        $('.backtype' + type).show();
    }
	$(function(){
		
		$('form').submit(function(){
			
			if($(':input[name=couponname]').isEmpty()){
				Tip.focus($(':input[name=couponname]'),'请输入优惠券名称!');
				return false;
			}
			var backtype = $(':radio[name=backtype]:checked').val();
			if(backtype=='0'){
				if($(':input[name=deduct]').isEmpty()){
					Tip.focus($(':input[name=deduct]'),'请输入立减多少!');
					return false;
				}
			}else if(backtype=='1'){
				if($(':input[name=discount]').isEmpty()){
					Tip.focus($(':input[name=discount]'),'请输入折扣多少!');
					return false;
				}
			}else if(backtype=='2'){
				if($(':input[name=backcredit]').isEmpty() && $(':input[name=backmoney]').isEmpty() && $(':input[name=backredpack]').isEmpty()){
					Tip.focus($(':input[name=backcredit]'),'至少输入一种返利!');
					return false;
				}
			}
			return true;
		})
		
	})
</script>
	
{/if}
{template 'web/_footer'}
